$(function () {
    getServiceTypeFindAll();
})

function getServiceTypeFindAll() {
    $.ajax({
        url: '/back/serviceType/findType',
        data: '',
        dataType: 'json',
        type: 'get',
        success: function (data) {
            data = data.list;
            let html = "";
            for (let i = 0; i < data.length; i++) {
                html += '<option value="' + data[i].id + '">' + data[i].serviceType + '</option>';
            }
            $("#roomType").html(html);//将页面格式加载到页面布局
        }

    })
}

/*文件取值  包含图片 全部转换为文件*/
function roomAdd() {
    let forData = new FormData();
    forData.append("roomId",$("#roomId").val());
    forData.append("roomType",$("#roomType").val());
    forData.append("roomPrice",$("#roomPrice").val());
    forData.append("roomTitle",$("#roomTitle").val());
    forData.append("roomPhoto", $("#roomPhoto")[0].files[0]);//文件取值
    forData.append("roomIntroduce",$("#roomIntroduce").val());
    $.ajax({
        url: '/back/room/roomAdd',
        data: forData,
        contentType:false,
        processData:false,
        type: 'post',
        dataType: 'json',
        success: function (data) {
            if (data.result === 1) {
                alert("提交成功")
                $("#right").load('../back/room/roomList.html');
            } else {
                alert("提交失败")
            }
        }
    })
}